<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <script src="../js/vue.js"></script>
    <script src="../js/echarts.js"></script>
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../js/echarts.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/elementui/index.js"></script>
    <!--引入ElementUI样式 -->

</head>
<body class="hold-transition">
<div id="app">
        <div class="content-header">
            <h1>统计分析<small>套餐占比</small></h1>
            <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>统计分析</el-breadcrumb-item>
                <el-breadcrumb-item>套餐占比</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
    <div class="app-container">
        <div class="box">
            <div>
                <template>
                    <div class="block">
                        <span class="demonstration"></span>
                        <el-date-picker
                                v-model="value"
                                type="daterange"
                                align="right"
                                unlink-panels
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :picker-options="pickerOptions">
                        </el-date-picker>
                        <el-button @click="findRangeCount()" class="dalfBut">查询</el-button>
                    </div>
                </template>
            </div>
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
        </div>
    </div>
</div>
<div id="chart1" style="height:600px;"></div>
<script>

    var myChart1 = echarts.init(document.getElementById('chart1'));
        new Vue({
            el: '#app',
            data :{
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                value: ''
        },
            methods: {
                findRangeCount(){
                    var sz=this.value.toString().split(",");
                    var d = new Date(sz[0]);
                    d=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() ;
                    var d1 = new Date(sz[1]);
                    d1=d1.getFullYear() + '-' + (d1.getMonth() + 1) + '-' + d1.getDate() ;
                    axios.get("/report/getOrderReport.do?start="+d+"&last="+d1).then((res)=>{
                        myChart1.setOption(
                            {
                                title: {
                                    text: '每日预约,到诊数量统计'
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                legend: {
                                    data:['每日预约数量','每日到诊数量']
                                },
                                xAxis: {
                                    type: 'category',
                                    data: res.data.data.days
                                },
                                yAxis: {
                                    type:'value'
                                },
                                series: [{
                                    name: '每日预约数量',
                                    type: 'line',
                                    data: res.data.data.dayCount
                                },
                                    {
                                        name: '每日到诊数量',
                                        type: 'line',
                                        data: res.data.data.dayCount1
                                    }]
                            });
                    });
                }
            }
    })
</script>
</body>
</html>